home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!juggler
- From: juggler@iquest.net (Phil Paxton)
- Subject: Re: Shuffle
- X-Nntp-Posting-Host: dorite.iquest.net
- Message-ID: <juggler.821846324@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Internet, Inc.
- X-Newsreader: NN version 6.5.0 #9 (NOV)
- References: <at-1601961212280001@sm1.psy.soton.ac.uk>
- Date: Wed, 17 Jan 1996 02:38:44 GMT
-
- at@neuro.psy.soton.ac.uk (Adriaan Tijsseling) writes:
-
- >For my neural network simulator I need a piece of code which shuffles
- >a set of n patterns in a random way. I.e. a set of 4 patterns would
- >then be shuffled such that I have a set of m orders of these patterns:
-
- >1 2 3 4
- >4 3 1 2
- >2 1 3 4
-
- Isn't the standard shuffling algorithm to order the list, then loop
- backward from the last object to the first. For each object, generate a
- random # in the range of 0:n, then swap the objects at the generated
- random # and the current index. By the time you reach the first object,
- the list will be randomized.
-
-
- --
- ------------------------------------
- Phil Paxton :: Fishers, Indiana, USA
-